package com.haixin.test.controller;

import com.haixin.test.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * 请修改注释
 *
 * @author zhangjianshe
 * @date 2021.07.21
 */
@Controller
public class UserThymeleafController {
    @GetMapping("/user")
    public ModelAndView testThymeleaf(){
        List<User> userList = new ArrayList<>();
        User user1 = new User();
        user1.setId(1L);
        user1.setNickName("张三");
        user1.setMobile("12345678777");
        user1.setPassword("123456");
        user1.setRole("user");
        User user2 = new User();
        user2.setId(2L);
        user2.setNickName("李四");
        user2.setMobile("99999999999");
        user2.setPassword("123456");
        user2.setRole("admin");
        userList.add(user1);
        userList.add(user2);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("userList",userList);
        modelAndView.setViewName("users.html");
        return modelAndView;
    }
}
